<script setup lang="ts">
import { ref } from 'vue';
import router from './router';


const inpValue = ref('')
// 路由跳转
const jump = () => { 
  // 路径跳转
  // router.push('/search')

  // qurey 跳转和传参 接收参数使用query.keyword接收
   router.push({
    path: '/search',
    query: {
      keyword: inpValue.value
    }
   })
  
  // name命名路由跳转和传参
  router.push({
    name: 'search',
    params: {
      keyword: inpValue.value
    }
  })
}
</script>

<template>
  <div class="home">
   <div class="logo-box"></div>
    <div class="search-box">
      <input type="text" v-model="inpValue">
      <button @click="jump">搜索一下</button>
    </div>
     <div class="hot-link">
      热门搜索：
      <!-- <router-link to="/search?keyword=苹果">apple</router-link>
      <router-link to="/search?keyword=橙子">orange</router-link>
      <router-link to="/search?keyword=香蕉">blanana</router-link> -->
       <router-link to="/search/苹果">apple</router-link>
      <router-link to="/search/橙子">orange</router-link>
      <router-link to="/search/香蕉">blanana</router-link>
    </div>
  </div>
  <div class="top">
    <router-view></router-view>
  </div>
</template>

<style scoped>
body {
  margin: 0;
  padding: 0;
}

.footer_wrap {
  position: relative;
  left: 0;
  top: 0;
  display: flex;
  width: 100%;
  text-align: center;
  background-color: #333;
  color: #ccc;
}

.footer_wrap a {
  flex: 1;
  text-decoration: none;
  padding: 20px 0;
  line-height: 20px;
  background-color: #333;
  color: #ccc;
  border: 1px solid black;
}

.footer_wrap a.router-link-active {
  background-color: red;
}

.footer_wrap a:hover {
  background-color: #555;
}
</style>
